<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!-- 加载配置文件 包函：图片 js css  -->
 <%@ include file="/WEB-INF/jsp/csy/common/wechatLibs.jsp"%>

<head>
    <title>微信登录</title>
<%--     <script  type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-3.1.1.min.js"></script> --%>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
</head>
<body>
    <div class="loginbox">
        <div class="avatar">
        <input  type="hidden" id="openid"  value="${customUserPO.openid}" 	>
       <c:if test="${ empty customUserPO.photo}">
       			     <!-- 微信LoGo ↓  -->
		<img src="/bsc/static/wechat/images/ico-wechat.png" style="width:150px;height:150px" /></c:if>
		<c:if test="${not empty customUserPO.photo}"><img src="${ctx}/${customUserPO.photo }" style="width:150px;height:150px" /></c:if>
        </div>
        <div class="login-input">
            <div class="input-text"><i class="ico-phone"></i><input type="text" id="mobile" name="mobile" placeholder="请输入手机号码"></div>
            <div class="input-text" style="display: show">
				<i class="ico-password"></i><input class="code" id="password"
					name="password" type="password" placeholder="请输入密码">
			</div>
            <input type="button" onclick="login()" value="登录">
        </div>
    </div>
</body>
<script type="text/javascript">
var mobileReg = /^1[3|4|5|8|9]\d{9}$/;
function login() {
	var mobile = $("#mobile").val();
	var checkCode = $("#password").val();
	if (mobile == '') {
		alert("请输入手机号码");
		return false;
	}
	if (checkCode == '') {
		alert("请输入验证码");
		return false;
	}
	if (!mobileReg.test(mobile)) { //验证手机号码
		alert("输入手机号码不合法")
		return;
	}
	var openid=$("#openid").val();
	
	$.ajax({
		type : 'post',
		url : '/bsc/wechat/vaildate',
		data : {
			mobile : mobile,
			checkCode:checkCode,
		},
		dataType : 'json',
		success : function(data) {
			alert(data);
			if (data=='1') {
				toast.fail({
					title : "登陆成功",
					duration : 2000
				});
				window.location.href = '/bsc/wechat/findProject';
			} else {
				toast.fail({
					title : "账号密码有误，请注册",
					duration : 3000
				});
			}
		},
		error : function() {
			toast.fail({
				title : "登陆失败，网络异常",
				duration : 2000
			});
		}
	}) 

}
</script>
</html>